home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / dev / misc / FD2Pragma.lha / Source / SDI_ASM_STD_protos.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-02  |  5.0 KB  |  142 lines

  1. #ifndef SDI_ASM_STD_PROTOS_H
  2. #define SDI_ASM_STD_PROTOS_H
  3.  
  4. /* Includeheader
  5.  
  6.     Name:        SDI_ASM_STD_protos
  7.     Versionstring:    $VER: SDI_ASM_STD_protos.h 1.15 (27.07.97)
  8.     Author:        SDI
  9.     Distribution:    PD
  10.     Description:    my replacement for standard ANSI functions
  11.  
  12.  1.9   18.11.96 : converted text into english language, changed C++ comments
  13.      to C ones
  14.  1.10  29.11.96 : added printf
  15.  1.11  06.02.97 : added exit prototype
  16.  1.12  28.03.97 : added some additionally defines (AMIGA_TO_ANSI), added
  17.      vsprintf
  18.  1.13  31.05.97 : fixed SDI_isprintf
  19.  1.14  20.07.97 : changed UBYTE ** to STRPTR *
  20.  1.15  27.07.97 : fixed SDI_printf
  21. */
  22.  
  23. /* These are mainly the normal ANSI C functions, but with an ASM interface.
  24. You can replace them by their normal functions supplied with your compiler,
  25. but do not mix them up (one object file standard, the other one SDI).
  26.  
  27. differences:
  28.  toupper and tolower: chars (0x41 to 0x5A) and (0xC0 to 0xDE) are upper
  29.   chars (0x61 to 0x79) and (0xE0 to 0xFE) are lower (some more than in ANSI)
  30.  isprint: chars (0x20 to 0x7E) and (0xA0 to 0xFF) are printable
  31.  sprintf and printf: only support exec/RawDoFmt format strings
  32.  and some I do not remember.
  33.  
  34.  all: return values may not match ANSI-C ones
  35.  
  36. printf: Use this function only for programs need to work under OS1.3. For
  37. OS2.0 (and up) only programs use dos.library/amiga.lib Printf function.
  38. */
  39.  
  40. #include <exec/types.h>
  41.  
  42. #ifdef __MAXON__
  43.   #define __asm
  44. #endif
  45.  
  46. #ifdef __cplusplus
  47. extern "C" {
  48. #endif
  49.  
  50. BYTE __asm SDI_strnicmp(register __a0 STRPTR,    /* string 1            */
  51.             register __a1 STRPTR,    /* string 2            */
  52.             register __d1 ULONG);    /* highest testlength        */
  53. BYTE __asm SDI_strncmp(    register __a0 STRPTR,    /* string 1            */
  54.             register __a1 STRPTR,    /* string 2            */
  55.             register __d1 ULONG);    /* highest testlength        */
  56. UBYTE __asm SDI_tolower(register __d0 UBYTE);    /* character to convert        */
  57. UBYTE __asm SDI_toupper(register __d0 UBYTE);    /* character to convert        */
  58. ULONG __asm SDI_strlen( register __a0 STRPTR);    /* string            */
  59. ULONG __asm SDI_isprint(register __d0 UBYTE);    /* character to convert        */
  60. ULONG __asm SDI_isdigit(register __d0 UBYTE);    /* character to convert        */
  61. ULONG __asm SDI_isxdigit(register __d0 UBYTE);    /* character to convert        */
  62. ULONG __asm SDI_isalnum(register __d0 UBYTE);    /* character to convert        */
  63. ULONG __asm SDI_isupper(register __d0 UBYTE);    /* character to convert        */
  64. ULONG __asm SDI_strtoul(register __a1 STRPTR,    /* buffer            */
  65.             register __a0 STRPTR *,    /* UBYTE var for error position    */
  66.             register __d2 UBYTE);     /* base                */
  67. ULONG __asm SDI_strtol(    register __a1 STRPTR,    /* buffer            */
  68.             register __a0 STRPTR *,    /* UBYTE var for error position */
  69.             register __d2 UBYTE);     /* base                */
  70. STRPTR __asm SDI_strncpy(register __a1 STRPTR,    /* string 1            */
  71.             register __a0 STRPTR,    /* string 2            */
  72.             register __d1 ULONG);    /* highest copy number        */
  73. void __asm SDI_memset(    register __a1 APTR,    /* buffer            */
  74.             register __d0 UBYTE,    /* fill character        */
  75.             register __d1 ULONG);    /* number of bytes        */
  76. STRPTR __asm SDI_strchr(register __a1 STRPTR,    /* buffer            */
  77.             register __d0 UBYTE);    /* character to scan for    */
  78. void __asm SDI_vsprintf(register __a3 STRPTR,    /* buffer            */
  79.             register __a0 STRPTR,    /* formatstring            */
  80.             register __a1 APTR);    /* data                */
  81. void SDI_sprintf(STRPTR, STRPTR, ...);        /* buffer, formatstring, data    */
  82. void SDI_printf(STRPTR, ...);            /* formatstring, data        */
  83.  
  84. #ifdef __cplusplus
  85. }
  86. #endif
  87.  
  88. #define SDI_stricmp(a,b)    SDI_strnicmp(a,b,~0)
  89. #define SDI_strcmp(a,b)        SDI_strncmp(a,b,~0)
  90. #define SDI_strcpy(a,b)        SDI_strncpy(a,b,~0)
  91.  
  92. /* Set SDI_TO_ANSI if you want to use normal ANSI names. Do not include
  93. the ANSI files stdio.h / stdlib.h ... , because this may result in an error */
  94.  
  95. #ifdef SDI_TO_ANSI
  96.   #define strnicmp    SDI_strnicmp
  97.   #define strncmp    SDI_strncmp
  98.   #define stricmp    SDI_stricmp
  99.   #define strcmp    SDI_strcmp
  100.   #define tolower    SDI_tolower
  101.   #define toupper    SDI_toupper
  102.   #define strlen    SDI_strlen
  103.   #define isprint    SDI_isprint
  104.   #define isdigit    SDI_isdigit
  105.   #define isxdigit    SDI_isxdigit
  106.   #define isalnum    SDI_isalnum
  107.   #define strtoul    SDI_strtoul
  108.   #define strtol    SDI_strtol
  109.   #define strncpy    SDI_strncpy
  110.   #define strcpy    SDI_strcpy
  111.   #define strchr    SDI_strchr
  112.   #define memset    SDI_memset
  113.   #define sprintf    SDI_sprintf
  114.   #define printf    SDI_printf
  115.   #define vsprintf    SDI_vsprintf
  116.  
  117.   extern void exit(int);
  118. #endif
  119.  
  120. /* Use the following with care, as they may collide with ANSI-C Standard
  121.    a lot more, than the above ones. The FILE * parameter of the functions
  122.    is converted into a filehandle of dos.library. Do not mix normal ANSI-C
  123.    and these functions! */
  124.  
  125. /* These defines are in experimental state !!! */
  126.  
  127. #ifdef AMIGA_TO_ANSI
  128.   #define memcpy(a,b,c)        CopyMem(b,a,c)
  129.   #define remove(a)        !DeleteFile(a)
  130.   #define rename(a,b)        !Rename(a,b)
  131.   #define putchar(a)        FPutC(Output(),a)
  132.   #define putc(a, b)        FPutC((ULONG) b, a)
  133.   #define getchar()        FGetC(Input())
  134.   #define getc(a)        FGetC((ULONG) a)
  135.   #define ungetc(a,b)        UnGetC((ULONG) b,a)
  136.   #define vprintf(a,b)        VPrintf(a,b)
  137.   #define vfprintf(a,b,c)    VFPrintf((ULONG) a, b, c)
  138.   #define fclose(a)        Close(a)
  139. #endif
  140.  
  141. #endif /* SDI_ASM_STD_PROTOS_H */
  142.